#include "stm32f10x.h"
#include "io.h"
#include "delay.h"
#include "led.h"
#include "beep.h"
#include "key.h"
#include "iwdg.h"


void keydown(void);

int main()
{
	ledinit();
	beepinit();
	keyinit();
	LED0=1;
	LED1=0;
	delay_ms(500);
	iwdginit(4,625);
	LED0=0;
	LED1=1;
	while(1)
	{
		if(keyscan(0)==WKUPPRES)
		{
			iwdgfeed();
		}
//		delay_ms(10);
	}
}

void keydown(void)
{
	u8 key;
	while(1)
	{
		key=keyscan(0);
		if(key)
		{
			switch(key)
			{
				case	KEY0PRES:
					LED0=!LED0;
					break;
				case	KEY1PRES:
					LED1=!LED1;
					break;
				case	WKUPPRES:
					BEEP=!BEEP;
					break;
			}
		}
		else delay_ms(10);
	}
}
